package com.healthyeating.manage.service.impl;

import java.util.List;
import com.healthyeating.common.utils.DateUtils;
import com.healthyeating.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.healthyeating.manage.mapper.NutritionMapper;
import com.healthyeating.manage.domain.Nutrition;
import com.healthyeating.manage.service.INutritionService;

/**
 * 成分列表Service业务层处理
 * 
 * @author 段奇乐
 * @date 2025-01-03
 */
@Service
public class NutritionServiceImpl implements INutritionService 
{
    @Autowired
    private NutritionMapper nutritionMapper;

    /**
     * 查询成分列表
     * 
     * @param nutritionId 成分列表主键
     * @return 成分列表
     */
    @Override
    public Nutrition selectNutritionByNutritionId(Long nutritionId)
    {
        return nutritionMapper.selectNutritionByNutritionId(nutritionId);
    }

    /**
     * 查询成分列表列表
     * 
     * @param nutrition 成分列表
     * @return 成分列表
     */
    @Override
    public List<Nutrition> selectNutritionList(Nutrition nutrition)
    {
        return nutritionMapper.selectNutritionList(nutrition);
    }

    /**
     * 新增成分列表
     * 
     * @param nutrition 成分列表
     * @return 结果
     */
    @Override
    public int insertNutrition(Nutrition nutrition)
    {
        nutrition.setCreateTime(DateUtils.getNowDate());
        nutrition.setUpdateTime(DateUtils.getNowDate());
        nutrition.setCreateBy(SecurityUtils.getUsername());
        return nutritionMapper.insertNutrition(nutrition);
    }

    /**
     * 修改成分列表
     * 
     * @param nutrition 成分列表
     * @return 结果
     */
    @Override
    public int updateNutrition(Nutrition nutrition)
    {
        nutrition.setUpdateTime(DateUtils.getNowDate());
        return nutritionMapper.updateNutrition(nutrition);
    }

    /**
     * 批量删除成分列表
     * 
     * @param nutritionIds 需要删除的成分列表主键
     * @return 结果
     */
    @Override
    public int deleteNutritionByNutritionIds(Long[] nutritionIds)
    {
        return nutritionMapper.deleteNutritionByNutritionIds(nutritionIds);
    }

    /**
     * 删除成分列表信息
     * 
     * @param nutritionId 成分列表主键
     * @return 结果
     */
    @Override
    public int deleteNutritionByNutritionId(Long nutritionId)
    {
        return nutritionMapper.deleteNutritionByNutritionId(nutritionId);
    }
}
